import { Injectable } from '@angular/core'
import { ObservableStore } from '@shared/classes/ObservableStoreClass'
import { deepCopy } from '@delon/util'
import { Terminal, TerminalNewRequest } from '@shared/interfaces/terminal'
import { Subject } from 'rxjs'

@Injectable()
export class TerminalStoreService extends ObservableStore<TerminalNewRequest> {
  constructor() {
    super(new TerminalNewRequest())
  }

  updateValue(group: TerminalNewRequest): void {
    /* 将传入的 group 和旧的 group 进行合并,注意多级嵌套 */
    const value = deepCopy(this.value)
    Object.assign(value, group)
    this.setValue(value)
  }

  reset(): void {
    this.setValue(new TerminalNewRequest())
  }
}
